import { getResponsiveSize } from '~utils/util'

// 生成指定范围内的随机整数
const getRandomInt = (min = 1000, max = 2000) => {
  return Math.floor(Math.random() * (max - min + 1)) + min
}

// 获取指定时间段内的x轴数据
const getXData = (xDataLen) => {
  return Array.from({ length: xDataLen }, (v, k) => {
    return `系列${k}`
  })
}

// 获取指定时间段内的series数据
const getSeriesData = (seriesDataLen, min, max) => {
  return Array.from({ length: seriesDataLen }, (v, k) => {
    return getRandomInt(min, max)
  })
}

export const chart = {
  chartData1: {
    chartData: {
      xData: getXData(9),
      seriesData: [
        {
          name: 'A',
          data: getSeriesData(9),
          type: 'bar',
          barWidth: getResponsiveSize(50),
          animationDelay(idx) {
            return idx * 300
          }
        },
        {
          name: 'B',
          data: getSeriesData(9),
          type: 'bar',
          barWidth: getResponsiveSize(50),
          animationDelay(idx) {
            return idx * 300 + 150
          }
        }
      ]
    },
    unit: '个',
    colorList: ['#1BB8FA', '#FFFC28']
  }
}
